home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / cracking software / pgp cracker.zip / idea.h < prev    next >
C/C++ Source or Header  |  1996-04-27  |  2KB  |  56 lines

  1. #ifndef IDEA_H
  2. #define IDEA_H
  3.  
  4. /*
  5.  *    idea.h - header file for idea.c
  6.  */
  7.  
  8. #include "usuals.h"  /* typedefs for byte, word16, boolean, etc. */
  9.  
  10. #define IDEAKEYSIZE 16
  11. #define IDEABLOCKSIZE 8
  12.  
  13. #define IDEAROUNDS 8
  14. #define IDEAKEYLEN (6*IDEAROUNDS+4)
  15.  
  16. /*
  17.  * iv[] is used as a circular buffer.  bufleft is the number of
  18.  * bytes at the end which have to be filled in before we crank
  19.  * the block cipher again.  We do the block cipher operation
  20.  * lazily: bufleft may be 0.  When we need one more byte, we
  21.  * crank the block cipher and set bufleft to 7.
  22.  *
  23.  * oldcipher[] holds the previous 8 bytes of ciphertext, for use
  24.  * by ideaCfbSync() and Phil's, ahem, unique (not insecure, just
  25.  * unusual) way of doing CFB encryption.
  26.  */
  27. struct IdeaCfbContext {
  28.     byte oldcipher[8];
  29.     byte iv[8];
  30.     word16 key[IDEAKEYLEN];
  31.     int bufleft;
  32. };
  33.  
  34. struct IdeaRandContext {
  35.     byte outbuf[8];
  36.     word16 key[IDEAKEYLEN];
  37.     int bufleft;
  38.     byte internalbuf[8];
  39. };
  40.  
  41. void ideaCfbReinit(struct IdeaCfbContext *context, byte const *iv);
  42. void ideaCfbInit(struct IdeaCfbContext *context, byte const (key[16]));
  43. void ideaCfbSync(struct IdeaCfbContext *context);
  44. void ideaCfbDestroy(struct IdeaCfbContext *context);
  45. void ideaCfbEncrypt(struct IdeaCfbContext *context,
  46.             byte const *src, byte *dest, int count);
  47. void ideaCfbDecrypt(struct IdeaCfbContext *context,
  48.             byte const *src, byte *dest, int count);
  49. void ideaRandInit(struct IdeaRandContext *context, byte const (key[16]),
  50.           byte const (seed[8]));
  51. byte ideaRandByte(struct IdeaRandContext *c);
  52. void ideaRandWash(struct IdeaRandContext *c, struct IdeaCfbContext *cfb);
  53. void ideaRandState(struct IdeaRandContext *c, byte key[16], byte seed[8]);
  54.  
  55. #endif /* !IDEA_H */
  56.